﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using VideoClassLibrary.BusinessLogicLayer;
public partial class TrainClassManagement_TCCourseList :AdminUserBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            Bind();
        }
    }
    public void Bind()
    {
        CourseModule tm = new CourseModule();
        DataSet ds = new DataSet();
        int tcid =Convert.ToInt32( Request.QueryString["TCID"].ToString());
        string sqlwhere =  " and trainClassID=" + tcid;
        ds = tm.GetCourseListByWhere(this.SchoolID,sqlwhere);
        Repeater1.DataSource = getPage(ds);
        Repeater1.DataBind();
 
    }
    public string GetSchNameByID(int schid)
    {
        TeacherModule ta = new TeacherModule();
        string name = ta.GetSchNameByID(schid);
        return name;
    }
    public string GetTraClaNameByID(int tcid)
    {
        TrainClassModule tm = new TrainClassModule();
        string TCName = tm.GetTrainClassNameByID(tcid);
        return TCName;

    }
    public PagedDataSource getPage(DataSet ds)
    {
        this.pager.RecordCount = ds.Tables[0].Rows.Count;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ds.Tables[0].DefaultView;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = pager.CurrentPageIndex - 1;
        pds.PageSize = pager.PageSize;
        return pds;
    }
    protected void pager_PageChanged(object sender, EventArgs e)
    {
      Bind(); 
      
    }
    public void btnUpdate_Click(object sender, CommandEventArgs e)
    {
        Response.Redirect("UpdateCourse.aspx?CID=" + e.CommandArgument.ToString());
    }
}
